<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
namespace app\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use app\common\model\Liquor as LiquorModel;

class Liquor extends Command
{

    protected function configure()
    {
        $this->setName('liquor')
            ->setDescription('liquor expire');
    }

    protected function execute(Input $input, Output $output)
    {
        $liquor_model = new LiquorModel();
        $condition = [
            ['expire_time', '<=', time()],
            ['status', 'eq', 'deposit']
        ];
        $list = $liquor_model->where($condition)->select();
        $update = [];
        foreach ($list as $info) {
            $update[] = ['id' => $info->id, 'status' => 'expire'];
        }
        $liquor_model->saveAll($update);
    }
}
